package com.baosight.sczx.zm.cl.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.ep.ServiceEPBase;
import com.baosight.sczx.common.zm.cInterface.Department;

/**
 * 安全统计模块(报表展示)
 * 质量标准化\三违\隐患
 * <p>Title: ServiceZMCLR5.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 严洪浩
 * @version 1.0
 * <pre>Histroy:
 *          2011-9-6 上午03:27:12  严洪浩  Create
 *</pre>
 */
public class ServiceZMCLR5 extends ServiceEPBase {
	
	/**
	 * 
	 * <p>Function: initLoad</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCLR5</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-11-18上午09:08:01 严洪浩
	 * </p>
	 *
	 */
	@Override
	public EiInfo initLoad(EiInfo inInfo)
	{
		EiInfo outInfo = new EiInfo();
		outInfo.addBlock(Department.getInstance().getConstructionUnit("cmes.cl.department", "orgCode", "orgName", false));//隐患单位
		return outInfo;
	}
	
	/**
	 * 安全统计查询方法
	 * <p>Function: query</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCLR5</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-6-3下午01:56:44 高强
	 * </p>
	 *
	 */
	public EiInfo query(EiInfo inInfo) {
		EiInfo outInfo = new EiInfo();
		outInfo.addBlock(getAllData("result",inInfo));
		return outInfo;
	}
	
	/**
	 * 缺少注视
	 * <p>Function: getAllData</p>
	 * <p>Description: </p>
	 * <p>return value:EiBlock</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-9-6上午03:26:50 严洪浩
	 * </p>
	 *
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public  EiBlock getAllData(String _blockID,EiInfo inInfo) {
		List<Map>  _list = new ArrayList<Map>();
		Map<String, String> _args = new HashMap<String, String>();
		_blockID = _blockID == null ? "result" : _blockID;
		
		EiBlock block = new EiBlock(_blockID);

		EiColumn eiColumn = new EiColumn("class");
		eiColumn.setType("C");
		block.addMeta(eiColumn);

		eiColumn = new EiColumn("type");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("name");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("item");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("count");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		_args.put("fdResponseDepartmentId", inInfo.getString("fdResponseDepartmentId"));
		_args.put("fdBeginDate", inInfo.getString("fdBeginDate"));
		_args.put("fdEndDate", inInfo.getString("fdEndDate"));
		
		List<Map> rQualityList = dao.query("ZMCLRiskRecord.queryForQuality", _args);
		for(int i = 0; i < rQualityList.size(); i++) {
			_list.add(rQualityList.get(i));
		}
		
		List<Map> r5examinList = dao.query("ZMCLRiskRecord.queryFor5examin", _args);
		for(int i = 0; i < r5examinList.size(); i++) {
			_list.add(r5examinList.get(i));
		}
		
		List<Map> tQualityList = dao.query("ZMCLTernateDeregulation.queryForQuality", _args);
		for(int i = 0; i < tQualityList.size(); i++) {
			_list.add(tQualityList.get(i));
		}
		
		List<Map> t5examinList = dao.query("ZMCLTernateDeregulation.queryFor5examin", _args);
		for(int i = 0; i < t5examinList.size(); i++) {
			_list.add(t5examinList.get(i));
		}
		block.setRows(_list);
		return block;
	}
}
